#include <iostream>
#include <fstream>
#include <string>
#include "bounded_vector.h"
using namespace std;

string readAllCharacters(string fileName)
{
	char c;
	ifstream fin;
	string result = "";

	fin.open(fileName);

	while (fin >> c)
	{
		if ((c >= 'a' && c <= 'z') /*|| (c >= 'A' && c <= 'Z')*/)
		{
			result += c;
		}
	}
	return result;
	

}

void main4_31()
{
	char c = 'a';
	bounded_vector bv1('a', 'z');
	bounded_vector bv2('a', 'z');

	string text1 = readAllCharacters("char1.txt");
	string text2 = readAllCharacters("char2.txt");

	for (int i = 0; i < text1.size(); i++)
	{
		bv1[text1[i]] += 1;
	}

	for (int i = 0; i < text2.size(); i++)
	{
		bv2[text2[i]] += 1;
	}

	while (c <= 'z')
	{
		cout << c << ": " << bv1[c] - bv2[c] << ", " << bv1[c] << ", " << bv2[c] << endl;
		c++;
	}

	
}


void main4_32()
{
	bounded_vector bv1('a', 'z');
	bounded_vector bv2('a', 'z');
	string char1 = readAllCharacters("char1.txt");
	string char2 = readAllCharacters("char2.txt");

	for (int i = 0; i < char1.size(); i++)
	{
		bv1[char1[i]] += 1;
	}

	for (int i = 0; i < char2.size(); i++)
	{
		bv2[char2[i]] += 1;
	}

	char c = 'a';
	int totprombv1 = 0;
	int totprombv2 = 0;
	while (c <= 'z')
	{
		int bv1prom = 1000 * bv1[c] / bv1.total_sum();
		totprombv1 += bv1prom;
		int bv2prom = 1000 * bv2[c] / bv2.total_sum();
		totprombv2 += bv2prom;
		cout << c << ": " << bv1prom - bv2prom << " , " << bv1prom << " , " << bv2prom << endl;
		c++;
	}
}


void main()
{
	main4_31();
	main4_32();
	system("pause");
}